﻿@using NOSDC.Services.Extensions;

@model NOSDC.Models.UpcomingEvent
<div id="upcomingEvent">
    <div class="newsPosting">
        <div>
            <div class="leftIcon"></div>
            <div class="upcomingEvents">
                <div class="newsTitle">
                    Upcoming Events
                </div>
            </div>
        </div>
        <div class="rightIcon"></div>
    </div>

    @if (Model.Event != null)
    {
        <div class="eventWidgetTitle" style="font-weight:bold; padding-top:10px; padding-bottom:5px;">@Html.ActionLink(Model.Event.Title, "Index", "Events", new { Model.Event.EventID, Title = Model.Event.Title.ToSeoUrl() }, null)</div>
        <div>
            @if (!String.IsNullOrWhiteSpace(Model.Event.Logo)) {
                <div class="eventLogo" style="float:left; width:30px;  height:30px;padding-right:5px;"><img src="../../../Images/Logos/@Model.Event.Logo" alt="@Model.Event.Logo" /></div>
            }
            <div class="eventDesc" style="text-align:left;">@Html.Raw(Model.Event.Description)</div>
            <div class="eventDate" style="padding-top:5px;">
                <strong>When:</strong> @Model.Event.StartDate.ToString("MMMM d, yyyy hh:mm") 
            </div>
                <div class="eventLocation" style="padding-top:5px;">
                <strong>Where:</strong> @Model.Event.Location
            </div>

            <div id="eventSignup">
            @if (Membership.GetUser() != null)
            {
                if (Model.IsAttendingUpcomingEvent)
                {
                    <div id="attending" style="height:25px;line-height:23px;"><img style="vertical-align:middle;" src="../../../Images/information.png" alt="" /><span><strong>You are attending this event!</strong></span></div>
                }
                else
                {
                    using (Ajax.BeginForm("Attend", "Events", new { eventId = Model.Event.EventID, main = false }, new AjaxOptions { UpdateTargetId = "upcomingEvent", InsertionMode = InsertionMode.Replace, OnSuccess = "signupSuccess" }))
                    {
                        <input type="image" src="../../../Images/sign_o.png" alt="SignUp" />
                    }
                }
            }
            else
            {
                <strong>You must login to attend this event!</strong>
            }
            </div>
        </div>
    }
    else
    {
        <div style="text-align:center;padding-top:10px;">@Model.Error</div>
    }
</div>